﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework2b1
{
    class Program
    {
        static void Main()
        {
            //读入整数数组
            Console.WriteLine("请输入整数数组，以逗号分隔：");
            string input = Console.ReadLine();
            string[] numbersString = input.Split(',');
            int[] numbers = new int[numbersString.Length];
            for (int i = 0; i < numbersString.Length; i++)
            {
                numbers[i] = int.Parse(numbersString[i]);
            }

            //求最大值
            int max = numbers[0];
            for (int i = 0; i < numbers.Length; i++)
            {
                if (numbers[i] > max)
                {
                    max = numbers[i];
                }
            }

            //求最小值
            int min = numbers[0];
            for (int i = 0; i < numbers.Length; i++)
            {
                if (numbers[i] < min)
                {
                    min = numbers[i];
                }
            }

            //求和
            int sum = 0;
            for (int i = 0; i < numbers.Length; i++)
            {
                sum += numbers[i];
            }

            // 求平均值
            double average = (double)sum / numbers.Length;

            // 输出结果
            Console.WriteLine("数组的最大值是: " + max);
            Console.WriteLine("数组的最小值是: " + min);
            Console.WriteLine("数组的平均值是: " + average);
            Console.WriteLine("数组所有元素的和是: " + sum);

            Console.ReadLine();
        }
    }
}
